home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 733 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: mail2news.demon.co.uk!escan.demon.co.uk
  2. From: Bill Birrell <bill@escan.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Two strange C problems.
  5. Date: Mon, 08 Jan 1996 18:24:00
  6. Message-ID: <821126182.AA00163@escan.demon.co.uk>
  7. Reply-To: bill@escan.demon.co.uk
  8. X-NNTP-Posting-Host: escan.demon.co.uk
  9. X-Mail2News-Path: escan.demon.co.uk
  10.  
  11.  > PROBLEM 2 :
  12.  
  13.  > const escape=27;
  14.  > const cr=13;
  15.  > const bs=8;
  16.  
  17.  > If I replace the 27 with \27' or the 13 with '\13'
  18.  > then these loops don't
  19.  > work i.e. an infinite loop results. WHY?
  20.  
  21.     That is not really surprising. 27 decimal or escape is '\033' or '\x1b' -
  22. octal or hexadecimal by default. cr is '\r' or '\015' or '\x0d', nl is '\n' or
  23. '\012' or '\x0a', bs is '\010' or '\b' or '\x08'. These are all given in the
  24. reference manual(A.2.5.2). You have just made a mistake, that's all. Nothing important.
  25. I am told that some compilers allow '\d27' for escape, but I would not bank on
  26. it.
  27.  
  28.  > Also if I want to do somthing like this : puts("\24
  29.  > \25"); which should
  30.  > print the up and down arrows on the screen (ASCII 24
  31.  > and 25), but no, it
  32.  > prints some other ASCII characters.
  33.  
  34.     Same problem. Do it in octal.
  35.  
  36. --
  37. Regards,
  38. Bill Birrell.
  39. internet:       bill@escan.demon.co.uk
  40.